#include <gtest/gtest.h>
#include <iostream>

class SilentTestReporter : public ::testing::EmptyTestEventListener
{
    // 重写不需要的输出函数为空实现
    void OnTestProgramStart(const ::testing::UnitTest& /*unit_test*/) override {}
    void OnTestIterationStart(const ::testing::UnitTest& /*unit_test*/, int /*iteration*/) override {}
    void OnEnvironmentsSetUpStart(const ::testing::UnitTest& /*unit_test*/) override {}
    void OnTestCaseStart(const ::testing::TestCase& /*test_case*/) override {}
    void OnTestStart(const ::testing::TestInfo& /*test_info*/) override {}
    void OnTestPartResult(const ::testing::TestPartResult& /*test_part_result*/) override {}
    void OnTestEnd(const ::testing::TestInfo& /*test_info*/) override {}
    void OnTestCaseEnd(const ::testing::TestCase& /*test_case*/) override {}
    void OnEnvironmentsTearDownStart(const ::testing::UnitTest& /*unit_test*/) override {}
    void OnTestIterationEnd(const ::testing::UnitTest& /*unit_test*/, int /*iteration*/) override {}
    void OnTestProgramEnd(const ::testing::UnitTest& /*unit_test*/) override {}
};

int main(int argc, char **argv)
{
    ::testing::InitGoogleTest(&argc, argv);

    // 屏蔽默认打印
    ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();
    delete listeners.Release(listeners.default_result_printer());  // 删除默认监听器
    listeners.Append(new SilentTestReporter());                    // 添加自定义监听器

    std::cout << "this is my main fun" << std::endl;

    return RUN_ALL_TESTS();
}
